import {Body, Controller, Get, Inject, OnModuleInit, Post} from "@nestjs/common";
import {ApiOperation, ApiTags} from "@nestjs/swagger";
import {SysMenuService} from "../service/SysMenuService";
import {Result} from "../common/Result";
import {SysMenu} from "../entity/SysMenu";
import {SkipAuth} from "../auth/guard/GlobalGuardProvider";

@ApiTags("菜单模块")
@Controller("/sysMenu")
export class SysMenuController {
    @Inject()
    private sysMenuService: SysMenuService;

    /**
     * 菜单查询
     * @param sysMenu
     */
    @ApiOperation({summary: "菜单查询"})
    @Get("/list")
    async menuList(@Body() sysMenu: SysMenu) {
        let data = await this.sysMenuService.menuList(sysMenu);
        return Result.success("菜单查询", data)
    }

    /**
     * 添加菜单
     * @param sysMenu
     */
    @ApiOperation({summary: "添加菜单"})
    @Post("/add")
    async addMenu(@Body() sysMenu: SysMenu) {
        return this.sysMenuService.addMenu(sysMenu);
    }

    /**
     * 根据角色获取用户菜单
     */
    @ApiOperation({summary: "根据角色获取用户菜单"})
    @Get("/getUserNav")
    async getUserNav() {
        return await this.sysMenuService.getUserNav();
    }
}
